package com.tangtanwei.hotel.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangtanwei.hotel.controller.UserRoomNumberController;
import com.tangtanwei.hotel.entity.UserRoomNumber;
import com.tangtanwei.hotel.mapper.UserRoomNumberMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoomNumberService extends ServiceImpl<UserRoomNumberMapper,UserRoomNumber> {



    public List<UserRoomNumber> getAll(String userId, String keyword) {
        LambdaQueryWrapper<UserRoomNumber> wrapp;
        if (StringUtils.isNotBlank(keyword)){
            wrapp = new QueryWrapper<UserRoomNumber>().lambda().eq(UserRoomNumber::getUserId, userId).like(UserRoomNumber::getName, keyword);
        }else {
            wrapp = new QueryWrapper<UserRoomNumber>().lambda().eq(UserRoomNumber::getUserId, userId);
        }
        return super.list(wrapp);

    }
}
